//ref: https://www.cnblogs.com/sunchaothu/p/10551344.html
//https://en.cppreference.com/w/cpp/chrono/steady_clock/now


#ifndef WallTime_H
#define WallTime_H

#include <string>
#include <ctime>
#include <chrono>


class WallTime 
{
public:

    WallTime();
    WallTime(std::string name_)
    {
        name = name_;
        time_acc = 0.0;
    };

    ~WallTime();


    void update();

    void restart();


    double getTime(){return time_acc;}

    std::string getDateTime();

    std::string getDateTimeString();

    void print();

    time_t StringToDatetime(std::string str);

private:

    //Accumulated time in current timer
    double time_acc;

    //Last timer start
    double last_start;

    //WallTime name
    std::string name;
    
    std::chrono::time_point<std::chrono::steady_clock> chrono_start;
    std::chrono::time_point<std::chrono::steady_clock> chrono_end;
    std::chrono::duration<double> chrono_duration;


    std::string DatetimeToString(time_t time);
};

#endif
